package com.surfacing.rcp.model.entity;

import com.surfacing.rcp.model.common.AbstractMessage;

public class Dienststelle extends AbstractMessage {

	public final static String ID = "Dienststelle";

	private int id;
	private String dienststelle;

	/**
	 * Class constructor for a staff member
	 */
	public Dienststelle() {
		super(ID);
		// set default values
		id = -1;
		dienststelle = "";
	}

	/**
	 * Class constructor for a complete staff member
	 * 
	 * @param firstName
	 *            the first name
	 * @param lastName
	 *            the last name
	 * @param userName
	 *            the username of this member
	 */
	public Dienststelle(String dienststelle) {
		this();
		setDienststelle(dienststelle);
	}

	/**
	 * Class constructor for a complete staff member
	 */
	public Dienststelle(int id, String dienststelle) {
		this();
		setId(id);
		setDienststelle(dienststelle);
	}

	/**
	 * Returns a string based description of the object
	 * 
	 * @return the description of the object
	 */
	@Override
	public String toString() {
		return dienststelle;
	}

	/**
	 * Returns the calculated hash code based on the staff member id.<br>
	 * Two staff members have the same hash code if the id is the same.
	 * 
	 * @return the calculated hash code
	 */
	@Override
	public int hashCode() {
		return 31 + id;
	}

	/**
	 * Returns whether the objects are equal or not.<br>
	 * Two staff members are equal if, and only if, the id is the same.
	 * 
	 * @return true if the id is the same otherwise false.
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final Dienststelle other = (Dienststelle) obj;
		if (id != other.id)
			return false;
		return true;
	}

	// SETTERS AND GETTERS
	/**
	 * Returns the personal identification number.
	 * 
	 * @return the staffMemberId
	 */
	public int getId() {
		return id;
	}

	/**
	 * Sets the personal identification number.
	 * 
	 * @param staffMemberId
	 *            the personId to set
	 * @throws IllegalArgumentException
	 *             if the id is negative
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * Returns the last name
	 * 
	 * @return the lastName
	 */
	public String getDienststelle() {
		return dienststelle;
	}

	/**
	 * Sets the last name of this staff member
	 * 
	 * @param lastName
	 *            the last name to set
	 * @throws IllegalArgumentException
	 *             if the lastName is null or empty
	 */
	public void setDienststelle(String dienststelle) {
		if (dienststelle == null || dienststelle.trim().isEmpty())
			throw new IllegalArgumentException(
					"The dienststelle cannot be null or empty");
		this.dienststelle = dienststelle;
	}
}
